package com.leenmvc.core.web.controller;


import com.leenmvc.core.annotation.ApiDescription;
import com.leenmvc.core.annotation.Note;
import com.leenmvc.core.base.BaseController;
import com.leenmvc.core.security.entity.core.SysDict;
import com.leenmvc.core.utils.dictionary.Dict;
import com.leenmvc.core.base.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: zhousc
 * @Description: 字典表对外提供接口
 * @date: 2020/5/11
 */
@RestController
@ApiDescription("字典表对外提供接口")
@RequestMapping("system/sysDict")
public class SysDictController extends BaseController<Dict> {

    @Note("用于前端页面字典表调用，传入字典表类型")
    @GetMapping("getDictList")
    public Result getDictList(@RequestParam String dictType){
        List<SysDict> sysDicts = dictType(dictType);
        return new Result().ok(sysDicts);
    }

    @Note("用于前端页面字典表调用，传入字典表类型, 返回hashmap")
    @GetMapping("getKvs")
    public Result getKvs(@RequestParam String dictType){
        Map<String, Object> dictMap = getMapByType(dictType);
        return new Result().ok(dictMap);
    }
}
